<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="/admin/commons/taglib.jsp"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>后台管理</title>
    <s:include value="/layouts/treeView.jsp"></s:include>
    <script type="text/javascript">
        $(function(){
            $("#teacher").addClass("active");
            $("#teacher").find("ul li").eq(1).addClass("active");
        })
    </script>
    <style>
        .treeOne{
            width: 12%;float: left;
            font-size: 16px;
        }
        .radioSize{
            width: 20px;height: 20px;
        }
    </style>
</head>
<body>
    <div class="admin">
        <div class="panel">
            <div class="panel-head"><strong>添加教师</strong></div>
            <div class="panel-body">
                <form action="teacher!save.action" id="form" method="post" enctype="multipart/form-data">
                    <input id="teacherId" type="hidden" name="teacher.id" value="${teacher.id}"/>
                    <input type="hidden" name="teacher.thistime" value="${teacher.hasTeachNum}"/>

                    <div class="form-group">
                        <div class="label"><label for="name">用户名</label></div>
                        <div class="field">
                            <input type="text" class="input" id="name" name="teacher.name" size="50" placeholder="请输入教师名称"
                                   data-validate="required:请输入教师名称" value="${teacher.name}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="label"><label for="teachAge">教龄</label></div>
                        <div class="field">
                            <input type="number" class="input" id="teachAge" name="teacher.teachAge" size="50" placeholder="请输入教师教龄"
                                   data-validate="required:请输入教师教龄,double:必须为数字" value="${teacher.teachAge}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="label"><label >已授课数</label></div>
                        <div class="field">
                            <input type="number" class="input"  name="teacher.hasTeachNum" size="50" placeholder="请输入已授课数"
                                   data-validate="required:请输入已授课数,double:必须为数字" value="${teacher.hasTeachNum}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="label"><label for="level">级别</label></div>
                        <select id="level" class="border radius" style="width:100%;height:35px;" name="teacher.level">
                            <option value="1">初级教师</option>
                            <option value="2" <s:if test="teacher.level==2">selected="selected"</s:if>>中级教师</option>
                            <option value="3" <s:if test="teacher.level==3">selected="selected"</s:if>>高级教师</option>
                        </select>
                    </div>

                    <div class="form-group">
                        <div class="label"><label>性别</label></div>
                        <div class="field">
                            <input type="radio" name="teacher.sex" class="radioSize" value="男" checked="checked" />男
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="teacher.sex" class="radioSize" value="女"  />女
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="label"><label >头像</label></div>
                        <div class="field">
                            <a class="button input-file" href="javascript:void(0);">+ 浏览文件<input size="100" type="file"
                                      name="file" data-validate="required:请选择上传文件,regexp#.+.(jpg|jpeg|png|gif)$:只能上传jpg|gif|png格式文件"/></a>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="label"><label >简介</label></div>
                        <div class="field">
                            <textarea id="teacherDesc" name="teacher.teacherDesc" class="input" rows="5" cols="3" style="resize:none"
                                      placeholder="请输入教师简介">${teacher.teacherDesc}</textarea>
                        </div>
                    </div>

                    <button class="button bg-blue" onclick="return checkForm()">提交</button>
                </form>
            </div>
        </div>
        <s:if test="teacher!=null">
            <div class="panel">
                <div class="panel-head"><strong>请选择教师授课范围</strong></div>
                <div class="panel-body">
                    <s:iterator value="classifyList" status="st">
                        <ul class="treeOne">
                            <li><s:property value="name"/>
                                <ul>
                                    <s:iterator value="sonList" var="inner">
                                        <li><input type="checkbox" value="<s:property value='#inner.id'/>"
                                                <s:if test="#inner.hasChoose">checked="checked"</s:if>/>
                                            <s:property value="#inner.name"/></li>
                                    </s:iterator>
                                </ul>
                            </li>
                        </ul>
                    </s:iterator>

                    <div style="clear: both;"></div>
                </div>
            </div>
        </s:if>
    </div>
    <script>
        //初始化树结构~
        $(".treeOne").treeview();
        var teacherId = $('#teacherId').val();
        //技能绑定点击事件
        $(":checkbox").click(function(){
            var flag = $(this).prop('checked');
            var classifyId = $(this).val();
            $.ajax({
                'url':"teacher!modifyJn.action",
                'data' : {"teachClassify.flag" : flag,"teachClassify.teacherId" : teacherId,"teachClassify.classifyId" : classifyId},
                'type' : "post",
                'dataType' : "json",
                'success' : function(data) {

                },
                'error':function() {
                }
            });
        });

    </script>

</body>
</html>

